package f.f0.i;

import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import com.pgl.sys.ces.out.ISdkLite;
import f.f0.c;
import f.f0.i.g.f;
import g.a0;
import g.e;
import g.g;
import g.h;
import g.z;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;

/* compiled from: Http2Reader */
public final class o implements Closeable {
    public static final Logger e = Logger.getLogger(e.class.getName());
    public final g a;
    public final a b;
    public final boolean c;
    public final f.f0.i.d.a d;

    /* compiled from: Http2Reader */
    public interface b {
    }

    /* compiled from: Http2Reader */
    public static final class a implements z {
        public final g a;
        public int b;
        public byte c;
        public int d;
        public int e;
        public short f;

        public a(g gVar) {
            this.a = gVar;
        }

        public a0 B() {
            return this.a.B();
        }

        public long c(e eVar, long j) throws IOException {
            while (true) {
                int i = this.e;
                if (i == 0) {
                    this.a.f((long) this.f);
                    this.f = (short) 0;
                    if ((this.c & 4) != 0) {
                        return -1;
                    }
                    int i2 = this.d;
                    int r = o.r(this.a);
                    this.e = r;
                    this.b = r;
                    byte q0 = (byte) (this.a.q0() & ISdkLite.REGION_UNSET);
                    this.c = (byte) (this.a.q0() & ISdkLite.REGION_UNSET);
                    Logger logger = o.e;
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine(e.a(true, this.d, this.b, q0, this.c));
                    }
                    int J = this.a.J() & Integer.MAX_VALUE;
                    this.d = J;
                    if (q0 != (byte) 9) {
                        e.c("%s != TYPE_CONTINUATION", Byte.valueOf(q0));
                        throw null;
                    } else if (J != i2) {
                        e.c("TYPE_CONTINUATION streamId changed", new Object[0]);
                        throw null;
                    }
                } else {
                    long c = this.a.c(eVar, Math.min(j, (long) i));
                    if (c == -1) {
                        return -1;
                    }
                    this.e = (int) (((long) this.e) - c);
                    return c;
                }
            }
        }

        public void close() throws IOException {
        }
    }

    public o(g gVar, boolean z) {
        this.a = gVar;
        this.c = z;
        a aVar = new a(gVar);
        this.b = aVar;
        this.d = new f.f0.i.d.a(4096, aVar);
    }

    public static int a(int i, byte b, short s) throws IOException {
        short i2;
        if ((b & 8) != 0) {
            i2 = i2 - 1;
        }
        if (s <= i2) {
            return (short) (i2 - s);
        }
        e.c("PROTOCOL_ERROR padding %s > remaining length %s", Short.valueOf(s), Integer.valueOf(i2));
        throw null;
    }

    public static int r(g gVar) throws IOException {
        return (gVar.q0() & ISdkLite.REGION_UNSET) | (((gVar.q0() & ISdkLite.REGION_UNSET) << 16) | ((gVar.q0() & ISdkLite.REGION_UNSET) << 8));
    }

    public void close() throws IOException {
        this.a.close();
    }

    /* JADX WARNING: Removed duplicated region for block: B:152:0x02ad  */
    public boolean k(boolean r19, f.f0.i.o.b r20) throws java.io.IOException {
        /*
        r18 = this;
        r1 = r18;
        r0 = r20;
        r2 = 0;
        r3 = r1.a;	 Catch:{ IOException -> 0x02d6 }
        r4 = 9;
        r3.i0(r4);	 Catch:{ IOException -> 0x02d6 }
        r3 = r1.a;
        r3 = r(r3);
        r4 = 0;
        r5 = 1;
        if (r3 < 0) goto L_0x02c8;
    L_0x0016:
        r6 = 16384; // 0x4000 float:2.2959E-41 double:8.0948E-320;
        if (r3 > r6) goto L_0x02c8;
    L_0x001a:
        r6 = r1.a;
        r6 = r6.q0();
        r6 = r6 & 255;
        r6 = (byte) r6;
        if (r19 == 0) goto L_0x0037;
    L_0x0025:
        r7 = 4;
        if (r6 != r7) goto L_0x0029;
    L_0x0028:
        goto L_0x0037;
    L_0x0029:
        r0 = "Expected a SETTINGS frame but was %s";
        r3 = new java.lang.Object[r5];
        r5 = java.lang.Byte.valueOf(r6);
        r3[r2] = r5;
        f.f0.i.e.c(r0, r3);
        throw r4;
    L_0x0037:
        r7 = r1.a;
        r7 = r7.q0();
        r7 = r7 & 255;
        r7 = (byte) r7;
        r8 = r1.a;
        r8 = r8.J();
        r9 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r8 = r8 & r9;
        r9 = e;
        r10 = java.util.logging.Level.FINE;
        r10 = r9.isLoggable(r10);
        if (r10 == 0) goto L_0x005b;
    L_0x0054:
        r10 = f.f0.i.e.a(r5, r8, r3, r6, r7);
        r9.fine(r10);
    L_0x005b:
        r9 = 2;
        switch(r6) {
            case 0: goto L_0x01a4;
            case 1: goto L_0x00b1;
            case 2: goto L_0x0085;
            case 3: goto L_0x0080;
            case 4: goto L_0x007b;
            case 5: goto L_0x0076;
            case 6: goto L_0x0071;
            case 7: goto L_0x006c;
            case 8: goto L_0x0067;
            default: goto L_0x005f;
        };
    L_0x005f:
        r0 = r1.a;
        r2 = (long) r3;
        r0.f(r2);
        goto L_0x02c7;
    L_0x0067:
        r1.w(r0, r3, r8);
        goto L_0x02c7;
    L_0x006c:
        r1.o(r0, r3, r8);
        goto L_0x02c7;
    L_0x0071:
        r1.s(r0, r3, r7, r8);
        goto L_0x02c7;
    L_0x0076:
        r1.t(r0, r3, r7, r8);
        goto L_0x02c7;
    L_0x007b:
        r1.v(r0, r3, r7, r8);
        goto L_0x02c7;
    L_0x0080:
        r1.u(r0, r3, r8);
        goto L_0x02c7;
    L_0x0085:
        r6 = 5;
        if (r3 != r6) goto L_0x00a3;
    L_0x0088:
        if (r8 == 0) goto L_0x009b;
    L_0x008a:
        r2 = r1.a;
        r2.J();
        r2 = r1.a;
        r2.q0();
        r0 = (f.f0.i.g.f) r0;
        java.util.Objects.requireNonNull(r0);
        goto L_0x02c7;
    L_0x009b:
        r0 = new java.lang.Object[r2];
        r2 = "TYPE_PRIORITY streamId == 0";
        f.f0.i.e.c(r2, r0);
        throw r4;
    L_0x00a3:
        r0 = new java.lang.Object[r5];
        r3 = java.lang.Integer.valueOf(r3);
        r0[r2] = r3;
        r2 = "TYPE_PRIORITY length: %d != 5";
        f.f0.i.e.c(r2, r0);
        throw r4;
    L_0x00b1:
        if (r8 == 0) goto L_0x019c;
    L_0x00b3:
        r4 = r7 & 1;
        if (r4 == 0) goto L_0x00b9;
    L_0x00b7:
        r4 = 1;
        goto L_0x00ba;
    L_0x00b9:
        r4 = 0;
    L_0x00ba:
        r6 = r7 & 8;
        if (r6 == 0) goto L_0x00c8;
    L_0x00be:
        r6 = r1.a;
        r6 = r6.q0();
        r6 = r6 & 255;
        r6 = (short) r6;
        goto L_0x00c9;
    L_0x00c8:
        r6 = 0;
    L_0x00c9:
        r10 = r7 & 32;
        if (r10 == 0) goto L_0x00df;
    L_0x00cd:
        r10 = r1.a;
        r10.J();
        r10 = r1.a;
        r10.q0();
        r10 = r0;
        r10 = (f.f0.i.g.f) r10;
        java.util.Objects.requireNonNull(r10);
        r3 = r3 + -5;
    L_0x00df:
        r3 = a(r3, r7, r6);
        r15 = r1.q(r3, r6, r7, r8);
        r0 = (f.f0.i.g.f) r0;
        r3 = f.f0.i.g.this;
        r3 = r3.r(r8);
        if (r3 == 0) goto L_0x0113;
    L_0x00f1:
        r0 = f.f0.i.g.this;
        java.util.Objects.requireNonNull(r0);
        r3 = new f.f0.i.i;	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r12 = "OkHttp %s Push Headers[%s]";
        r13 = new java.lang.Object[r9];	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r6 = r0.d;	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r13[r2] = r6;	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r2 = java.lang.Integer.valueOf(r8);	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r13[r5] = r2;	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r10 = r3;
        r11 = r0;
        r14 = r8;
        r16 = r4;
        r10.m7725init(r11, r12, r13, r14, r15, r16);	 Catch:{ RejectedExecutionException -> 0x02c7 }
        r0.q(r3);	 Catch:{ RejectedExecutionException -> 0x02c7 }
        goto L_0x02c7;
    L_0x0113:
        r3 = f.f0.i.g.this;
        monitor-enter(r3);
        r6 = f.f0.i.g.this;	 Catch:{ all -> 0x0199 }
        r6 = r6.n(r8);	 Catch:{ all -> 0x0199 }
        if (r6 != 0) goto L_0x0171;
    L_0x011e:
        r6 = f.f0.i.g.this;	 Catch:{ all -> 0x0199 }
        r7 = r6.g;	 Catch:{ all -> 0x0199 }
        if (r7 == 0) goto L_0x0127;
    L_0x0124:
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        goto L_0x02c7;
    L_0x0127:
        r7 = r6.e;	 Catch:{ all -> 0x0199 }
        if (r8 > r7) goto L_0x012e;
    L_0x012b:
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        goto L_0x02c7;
    L_0x012e:
        r7 = r8 % 2;
        r6 = r6.f;	 Catch:{ all -> 0x0199 }
        r6 = r6 % r9;
        if (r7 != r6) goto L_0x0138;
    L_0x0135:
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        goto L_0x02c7;
    L_0x0138:
        r15 = f.f0.c.y(r15);	 Catch:{ all -> 0x0199 }
        r6 = new f.f0.i.p;	 Catch:{ all -> 0x0199 }
        r12 = f.f0.i.g.this;	 Catch:{ all -> 0x0199 }
        r13 = 0;
        r10 = r6;
        r11 = r8;
        r14 = r4;
        r10.m4755init(r11, r12, r13, r14, r15);	 Catch:{ all -> 0x0199 }
        r4 = f.f0.i.g.this;	 Catch:{ all -> 0x0199 }
        r4.e = r8;	 Catch:{ all -> 0x0199 }
        r4 = r4.c;	 Catch:{ all -> 0x0199 }
        r7 = java.lang.Integer.valueOf(r8);	 Catch:{ all -> 0x0199 }
        r4.put(r7, r6);	 Catch:{ all -> 0x0199 }
        r4 = f.f0.i.g.u;	 Catch:{ all -> 0x0199 }
        r7 = new f.f0.i.l;	 Catch:{ all -> 0x0199 }
        r10 = "OkHttp %s stream %d";
        r9 = new java.lang.Object[r9];	 Catch:{ all -> 0x0199 }
        r11 = f.f0.i.g.this;	 Catch:{ all -> 0x0199 }
        r11 = r11.d;	 Catch:{ all -> 0x0199 }
        r9[r2] = r11;	 Catch:{ all -> 0x0199 }
        r2 = java.lang.Integer.valueOf(r8);	 Catch:{ all -> 0x0199 }
        r9[r5] = r2;	 Catch:{ all -> 0x0199 }
        r7.m7728init(r0, r10, r9, r6);	 Catch:{ all -> 0x0199 }
        r4.execute(r7);	 Catch:{ all -> 0x0199 }
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        goto L_0x02c7;
    L_0x0171:
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        monitor-enter(r6);
        r6.f = r5;	 Catch:{ all -> 0x0196 }
        r0 = r6.e;	 Catch:{ all -> 0x0196 }
        r2 = f.f0.c.y(r15);	 Catch:{ all -> 0x0196 }
        r0.add(r2);	 Catch:{ all -> 0x0196 }
        r0 = r6.h();	 Catch:{ all -> 0x0196 }
        r6.notifyAll();	 Catch:{ all -> 0x0196 }
        monitor-exit(r6);	 Catch:{ all -> 0x0196 }
        if (r0 != 0) goto L_0x018f;
    L_0x0188:
        r0 = r6.d;
        r2 = r6.c;
        r0.s(r2);
    L_0x018f:
        if (r4 == 0) goto L_0x02c7;
    L_0x0191:
        r6.i();
        goto L_0x02c7;
    L_0x0196:
        r0 = move-exception;
        monitor-exit(r6);	 Catch:{ all -> 0x0196 }
        throw r0;
    L_0x0199:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x0199 }
        throw r0;
    L_0x019c:
        r0 = "PROTOCOL_ERROR: TYPE_HEADERS streamId == 0";
        r2 = new java.lang.Object[r2];
        f.f0.i.e.c(r0, r2);
        throw r4;
    L_0x01a4:
        if (r8 == 0) goto L_0x02bf;
    L_0x01a6:
        r6 = r7 & 1;
        if (r6 == 0) goto L_0x01ad;
    L_0x01aa:
        r17 = 1;
        goto L_0x01af;
    L_0x01ad:
        r17 = 0;
    L_0x01af:
        r6 = r7 & 32;
        if (r6 == 0) goto L_0x01b5;
    L_0x01b3:
        r6 = 1;
        goto L_0x01b6;
    L_0x01b5:
        r6 = 0;
    L_0x01b6:
        if (r6 != 0) goto L_0x02b7;
    L_0x01b8:
        r4 = r7 & 8;
        if (r4 == 0) goto L_0x01c6;
    L_0x01bc:
        r4 = r1.a;
        r4 = r4.q0();
        r4 = r4 & 255;
        r4 = (short) r4;
        goto L_0x01c7;
    L_0x01c6:
        r4 = 0;
    L_0x01c7:
        r3 = a(r3, r7, r4);
        r6 = r1.a;
        r0 = (f.f0.i.g.f) r0;
        r7 = f.f0.i.g.this;
        r7 = r7.r(r8);
        if (r7 == 0) goto L_0x0227;
    L_0x01d7:
        r0 = f.f0.i.g.this;
        java.util.Objects.requireNonNull(r0);
        r15 = new g.e;
        r15.m8403init();
        r10 = (long) r3;
        r6.i0(r10);
        r6.c(r15, r10);
        r6 = r15.b;
        r12 = (r6 > r10 ? 1 : (r6 == r10 ? 0 : -1));
        if (r12 != 0) goto L_0x020b;
    L_0x01ee:
        r6 = new f.f0.i.j;
        r13 = new java.lang.Object[r9];
        r7 = r0.d;
        r13[r2] = r7;
        r2 = java.lang.Integer.valueOf(r8);
        r13[r5] = r2;
        r12 = "OkHttp %s Push Data[%s]";
        r10 = r6;
        r11 = r0;
        r14 = r8;
        r16 = r3;
        r10.m7726init(r11, r12, r13, r14, r15, r16, r17);
        r0.q(r6);
        goto L_0x02b0;
    L_0x020b:
        r0 = new java.io.IOException;
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r4 = r15.b;
        r2.append(r4);
        r4 = " != ";
        r2.append(r4);
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x0227:
        r7 = f.f0.i.g.this;
        r7 = r7.n(r8);
        if (r7 != 0) goto L_0x0241;
    L_0x022f:
        r2 = f.f0.i.g.this;
        r7 = f.f0.i.b.PROTOCOL_ERROR;
        r2.w(r8, r7);
        r0 = f.f0.i.g.this;
        r2 = (long) r3;
        r0.u(r2);
        r6.f(r2);
        goto L_0x02b0;
    L_0x0241:
        r0 = r7.g;
        r8 = (long) r3;
        java.util.Objects.requireNonNull(r0);
    L_0x0247:
        r10 = 0;
        r3 = (r8 > r10 ? 1 : (r8 == r10 ? 0 : -1));
        if (r3 <= 0) goto L_0x02ab;
    L_0x024d:
        r3 = f.f0.i.p.this;
        monitor-enter(r3);
        r12 = r0.e;	 Catch:{ all -> 0x02a8 }
        r13 = r0.b;	 Catch:{ all -> 0x02a8 }
        r13 = r13.b;	 Catch:{ all -> 0x02a8 }
        r13 = r13 + r8;
        r10 = r0.c;	 Catch:{ all -> 0x02a8 }
        r15 = (r13 > r10 ? 1 : (r13 == r10 ? 0 : -1));
        if (r15 <= 0) goto L_0x025f;
    L_0x025d:
        r10 = 1;
        goto L_0x0260;
    L_0x025f:
        r10 = 0;
    L_0x0260:
        monitor-exit(r3);	 Catch:{ all -> 0x02a8 }
        if (r10 == 0) goto L_0x026e;
    L_0x0263:
        r6.f(r8);
        r0 = f.f0.i.p.this;
        r2 = f.f0.i.b.FLOW_CONTROL_ERROR;
        r0.e(r2);
        goto L_0x02ab;
    L_0x026e:
        if (r12 == 0) goto L_0x0274;
    L_0x0270:
        r6.f(r8);
        goto L_0x02ab;
    L_0x0274:
        r3 = r0.a;
        r10 = r6.c(r3, r8);
        r12 = -1;
        r3 = (r10 > r12 ? 1 : (r10 == r12 ? 0 : -1));
        if (r3 == 0) goto L_0x02a2;
    L_0x0280:
        r8 = r8 - r10;
        r3 = f.f0.i.p.this;
        monitor-enter(r3);
        r10 = r0.b;	 Catch:{ all -> 0x029f }
        r11 = r10.b;	 Catch:{ all -> 0x029f }
        r13 = 0;
        r15 = (r11 > r13 ? 1 : (r11 == r13 ? 0 : -1));
        if (r15 != 0) goto L_0x0290;
    L_0x028e:
        r11 = 1;
        goto L_0x0291;
    L_0x0290:
        r11 = 0;
    L_0x0291:
        r12 = r0.a;	 Catch:{ all -> 0x029f }
        r10.G(r12);	 Catch:{ all -> 0x029f }
        if (r11 == 0) goto L_0x029d;
    L_0x0298:
        r10 = f.f0.i.p.this;	 Catch:{ all -> 0x029f }
        r10.notifyAll();	 Catch:{ all -> 0x029f }
    L_0x029d:
        monitor-exit(r3);	 Catch:{ all -> 0x029f }
        goto L_0x0247;
    L_0x029f:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x029f }
        throw r0;
    L_0x02a2:
        r0 = new java.io.EOFException;
        r0.<init>();
        throw r0;
    L_0x02a8:
        r0 = move-exception;
        monitor-exit(r3);	 Catch:{ all -> 0x02a8 }
        throw r0;
    L_0x02ab:
        if (r17 == 0) goto L_0x02b0;
    L_0x02ad:
        r7.i();
    L_0x02b0:
        r0 = r1.a;
        r2 = (long) r4;
        r0.f(r2);
        goto L_0x02c7;
    L_0x02b7:
        r0 = "PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA";
        r2 = new java.lang.Object[r2];
        f.f0.i.e.c(r0, r2);
        throw r4;
    L_0x02bf:
        r0 = "PROTOCOL_ERROR: TYPE_DATA streamId == 0";
        r2 = new java.lang.Object[r2];
        f.f0.i.e.c(r0, r2);
        throw r4;
    L_0x02c7:
        return r5;
    L_0x02c8:
        r0 = "FRAME_SIZE_ERROR: %s";
        r5 = new java.lang.Object[r5];
        r3 = java.lang.Integer.valueOf(r3);
        r5[r2] = r3;
        f.f0.i.e.c(r0, r5);
        throw r4;
    L_0x02d6:
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.i.o.k(boolean, f.f0.i.o$b):boolean");
    }

    public void n(b bVar) throws IOException {
        if (!this.c) {
            g gVar = this.a;
            h hVar = e.a;
            h d = gVar.d((long) hVar.p());
            Logger logger = e;
            if (logger.isLoggable(Level.FINE)) {
                logger.fine(c.n("<< CONNECTION %s", d.k()));
            }
            if (!hVar.equals(d)) {
                e.c("Expected a connection header but was %s", d.w());
                throw null;
            }
        } else if (!k(true, bVar)) {
            e.c("Required SETTINGS preface not received", new Object[0]);
            throw null;
        }
    }

    public final void o(b bVar, int i, int i2) throws IOException {
        int i3 = 0;
        if (i < 8) {
            e.c("TYPE_GOAWAY length < 8: %s", Integer.valueOf(i));
            throw null;
        } else if (i2 == 0) {
            i2 = this.a.J();
            i -= 8;
            if (b.a(this.a.J()) != null) {
                p[] pVarArr;
                h hVar = h.e;
                if (i > 0) {
                    hVar = this.a.d((long) i);
                }
                f fVar = (f) bVar;
                Objects.requireNonNull(fVar);
                hVar.p();
                synchronized (g.this) {
                    pVarArr = (p[]) g.this.c.values().toArray(new p[g.this.c.size()]);
                    g.this.g = true;
                }
                i = pVarArr.length;
                while (i3 < i) {
                    p pVar = pVarArr[i3];
                    if (pVar.c > i2 && pVar.g()) {
                        b bVar2 = b.REFUSED_STREAM;
                        synchronized (pVar) {
                            if (pVar.k == null) {
                                pVar.k = bVar2;
                                pVar.notifyAll();
                            }
                        }
                        g.this.s(pVar.c);
                    }
                    i3++;
                }
                return;
            }
            e.c("TYPE_GOAWAY unexpected error code: %d", Integer.valueOf(this.a.J()));
            throw null;
        } else {
            e.c("TYPE_GOAWAY streamId != 0", new Object[0]);
            throw null;
        }
    }

    public final List<c> q(int i, short s, byte b, int i2) throws IOException {
        a aVar = this.b;
        aVar.e = i;
        aVar.b = i;
        aVar.f = s;
        aVar.c = b;
        aVar.d = i2;
        f.f0.i.d.a aVar2 = this.d;
        while (!aVar2.b.Q()) {
            int q0 = aVar2.b.q0() & ISdkLite.REGION_UNSET;
            int b2;
            StringBuilder g;
            h f;
            if (q0 == AesLen.ROOTKEY_COMPONET_LEN) {
                throw new IOException("index == 0");
            } else if ((q0 & AesLen.ROOTKEY_COMPONET_LEN) == AesLen.ROOTKEY_COMPONET_LEN) {
                q0 = aVar2.g(q0, 127) - 1;
                Object obj = (q0 < 0 || q0 > d.a.length - 1) ? null : 1;
                if (obj != null) {
                    aVar2.a.add(d.a[q0]);
                } else {
                    b2 = aVar2.b(q0 - d.a.length);
                    if (b2 >= 0) {
                        c[] cVarArr = aVar2.e;
                        if (b2 < cVarArr.length) {
                            aVar2.a.add(cVarArr[b2]);
                        }
                    }
                    g = c.b.a.a.a.g("Header index too large ");
                    g.append(q0 + 1);
                    throw new IOException(g.toString());
                }
            } else if (q0 == 64) {
                f = aVar2.f();
                d.a(f);
                aVar2.e(-1, new c(f, aVar2.f()));
            } else if ((q0 & 64) == 64) {
                aVar2.e(-1, new c(aVar2.d(aVar2.g(q0, 63) - 1), aVar2.f()));
            } else if ((q0 & 32) == 32) {
                q0 = aVar2.g(q0, 31);
                aVar2.d = q0;
                if (q0 < 0 || q0 > aVar2.c) {
                    g = c.b.a.a.a.g("Invalid dynamic table size update ");
                    g.append(aVar2.d);
                    throw new IOException(g.toString());
                }
                b2 = aVar2.h;
                if (q0 < b2) {
                    if (q0 == 0) {
                        aVar2.a();
                    } else {
                        aVar2.c(b2 - q0);
                    }
                }
            } else if (q0 == 16 || q0 == 0) {
                f = aVar2.f();
                d.a(f);
                aVar2.a.add(new c(f, aVar2.f()));
            } else {
                aVar2.a.add(new c(aVar2.d(aVar2.g(q0, 15) - 1), aVar2.f()));
            }
        }
        aVar2 = this.d;
        Objects.requireNonNull(aVar2);
        ArrayList arrayList = new ArrayList(aVar2.a);
        aVar2.a.clear();
        return arrayList;
    }

    public final void s(b bVar, int i, byte b, int i2) throws IOException {
        if (i != 8) {
            e.c("TYPE_PING length != 8: %s", Integer.valueOf(i));
            throw null;
        } else if (i2 == 0) {
            i = this.a.J();
            i2 = this.a.J();
            Object obj = (b & 1) != 0 ? 1 : null;
            f fVar = (f) bVar;
            Objects.requireNonNull(fVar);
            g gVar;
            if (obj != null) {
                synchronized (g.this) {
                    gVar = g.this;
                    gVar.k = false;
                    gVar.notifyAll();
                }
                return;
            }
            try {
                gVar = g.this;
                gVar.h.execute(new g.e(true, i, i2));
            } catch (RejectedExecutionException unused) {
            }
        } else {
            e.c("TYPE_PING streamId != 0", new Object[0]);
            throw null;
        }
    }

    public final void t(b bVar, int i, byte b, int i2) throws IOException {
        if (i2 != 0) {
            short q0 = (b & 8) != 0 ? (short) (this.a.q0() & ISdkLite.REGION_UNSET) : (short) 0;
            int J = this.a.J() & Integer.MAX_VALUE;
            List q = q(a(i - 4, b, q0), q0, b, i2);
            g gVar = g.this;
            synchronized (gVar) {
                if (gVar.t.contains(Integer.valueOf(J))) {
                    gVar.w(J, b.PROTOCOL_ERROR);
                    return;
                }
                gVar.t.add(Integer.valueOf(J));
                try {
                    gVar.q(new h(gVar, "OkHttp %s Push Request[%s]", new Object[]{gVar.d, Integer.valueOf(J)}, J, q));
                    return;
                } catch (RejectedExecutionException unused) {
                    return;
                }
            }
        }
        e.c("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0", new Object[0]);
        throw null;
    }

    public final void u(b bVar, int i, int i2) throws IOException {
        if (i != 4) {
            e.c("TYPE_RST_STREAM length: %d != 4", Integer.valueOf(i));
            throw null;
        } else if (i2 != 0) {
            b a = b.a(this.a.J());
            if (a != null) {
                f fVar = (f) bVar;
                if (g.this.r(i2)) {
                    g gVar = g.this;
                    g gVar2 = gVar;
                    gVar.q(new k(gVar2, "OkHttp %s Push Reset[%s]", new Object[]{gVar.d, Integer.valueOf(i2)}, i2, a));
                    return;
                }
                p s = g.this.s(i2);
                if (s != null) {
                    synchronized (s) {
                        if (s.k == null) {
                            s.k = a;
                            s.notifyAll();
                        }
                    }
                    return;
                }
                return;
            }
            e.c("TYPE_RST_STREAM unexpected error code: %d", Integer.valueOf(i));
            throw null;
        } else {
            e.c("TYPE_RST_STREAM streamId == 0", new Object[0]);
            throw null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:66:0x0110  */
    /* JADX WARNING: Missing exception handler attribute for start block: B:52:0x00be */
    /* JADX WARNING: Can't wrap try/catch for region: R(10:38|39|(5:42|(1:44)(1:45)|(2:47|102)(2:48|101)|49|40)|50|51|52|53|(1:62)(4:56|(1:58)|59|(1:61))|63|64) */
    public final void v(f.f0.i.o.b r10, int r11, byte r12, int r13) throws java.io.IOException {
        /*
        r9 = this;
        r0 = 0;
        r1 = 0;
        if (r13 != 0) goto L_0x013d;
    L_0x0004:
        r13 = 1;
        r12 = r12 & r13;
        if (r12 == 0) goto L_0x0018;
    L_0x0008:
        if (r11 != 0) goto L_0x0010;
    L_0x000a:
        r10 = (f.f0.i.g.f) r10;
        java.util.Objects.requireNonNull(r10);
        return;
    L_0x0010:
        r10 = "FRAME_SIZE_ERROR ack frame should be empty!";
        r11 = new java.lang.Object[r1];
        f.f0.i.e.c(r10, r11);
        throw r0;
    L_0x0018:
        r12 = r11 % 6;
        if (r12 != 0) goto L_0x012f;
    L_0x001c:
        r12 = new f.f0.i.t;
        r12.m4763init();
        r2 = 0;
    L_0x0022:
        if (r2 >= r11) goto L_0x007a;
    L_0x0024:
        r3 = r9.a;
        r3 = r3.c0();
        r4 = 65535; // 0xffff float:9.1834E-41 double:3.23786E-319;
        r3 = r3 & r4;
        r4 = r9.a;
        r4 = r4.J();
        r5 = 2;
        r6 = 4;
        if (r3 == r5) goto L_0x0067;
    L_0x0038:
        r5 = 3;
        if (r3 == r5) goto L_0x0065;
    L_0x003b:
        if (r3 == r6) goto L_0x0059;
    L_0x003d:
        r5 = 5;
        if (r3 == r5) goto L_0x0041;
    L_0x0040:
        goto L_0x0074;
    L_0x0041:
        r5 = 16384; // 0x4000 float:2.2959E-41 double:8.0948E-320;
        if (r4 < r5) goto L_0x004b;
    L_0x0045:
        r5 = 16777215; // 0xffffff float:2.3509886E-38 double:8.2890456E-317;
        if (r4 > r5) goto L_0x004b;
    L_0x004a:
        goto L_0x0074;
    L_0x004b:
        r10 = "PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s";
        r11 = new java.lang.Object[r13];
        r12 = java.lang.Integer.valueOf(r4);
        r11[r1] = r12;
        f.f0.i.e.c(r10, r11);
        throw r0;
    L_0x0059:
        r3 = 7;
        if (r4 < 0) goto L_0x005d;
    L_0x005c:
        goto L_0x0074;
    L_0x005d:
        r10 = "PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1";
        r11 = new java.lang.Object[r1];
        f.f0.i.e.c(r10, r11);
        throw r0;
    L_0x0065:
        r3 = 4;
        goto L_0x0074;
    L_0x0067:
        if (r4 == 0) goto L_0x0074;
    L_0x0069:
        if (r4 != r13) goto L_0x006c;
    L_0x006b:
        goto L_0x0074;
    L_0x006c:
        r10 = "PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1";
        r11 = new java.lang.Object[r1];
        f.f0.i.e.c(r10, r11);
        throw r0;
    L_0x0074:
        r12.b(r3, r4);
        r2 = r2 + 6;
        goto L_0x0022;
    L_0x007a:
        r10 = (f.f0.i.g.f) r10;
        r2 = f.f0.i.g.this;
        monitor-enter(r2);
        r11 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r11 = r11.o;	 Catch:{ all -> 0x012c }
        r11 = r11.a();	 Catch:{ all -> 0x012c }
        r3 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r3 = r3.o;	 Catch:{ all -> 0x012c }
        java.util.Objects.requireNonNull(r3);	 Catch:{ all -> 0x012c }
        r4 = 0;
    L_0x008f:
        r5 = 10;
        if (r4 >= r5) goto L_0x00aa;
    L_0x0093:
        r5 = r13 << r4;
        r6 = r12.a;	 Catch:{ all -> 0x012c }
        r5 = r5 & r6;
        if (r5 == 0) goto L_0x009c;
    L_0x009a:
        r5 = 1;
        goto L_0x009d;
    L_0x009c:
        r5 = 0;
    L_0x009d:
        if (r5 != 0) goto L_0x00a0;
    L_0x009f:
        goto L_0x00a7;
    L_0x00a0:
        r5 = r12.b;	 Catch:{ all -> 0x012c }
        r5 = r5[r4];	 Catch:{ all -> 0x012c }
        r3.b(r4, r5);	 Catch:{ all -> 0x012c }
    L_0x00a7:
        r4 = r4 + 1;
        goto L_0x008f;
    L_0x00aa:
        r3 = f.f0.i.g.this;	 Catch:{ RejectedExecutionException -> 0x00be }
        r4 = r3.h;	 Catch:{ RejectedExecutionException -> 0x00be }
        r5 = new f.f0.i.n;	 Catch:{ RejectedExecutionException -> 0x00be }
        r6 = "OkHttp %s ACK Settings";
        r7 = new java.lang.Object[r13];	 Catch:{ RejectedExecutionException -> 0x00be }
        r3 = r3.d;	 Catch:{ RejectedExecutionException -> 0x00be }
        r7[r1] = r3;	 Catch:{ RejectedExecutionException -> 0x00be }
        r5.m7730init(r10, r6, r7, r12);	 Catch:{ RejectedExecutionException -> 0x00be }
        r4.execute(r5);	 Catch:{ RejectedExecutionException -> 0x00be }
    L_0x00be:
        r12 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r12 = r12.o;	 Catch:{ all -> 0x012c }
        r12 = r12.a();	 Catch:{ all -> 0x012c }
        r3 = -1;
        r4 = 0;
        if (r12 == r3) goto L_0x00f8;
    L_0x00cb:
        if (r12 == r11) goto L_0x00f8;
    L_0x00cd:
        r12 = r12 - r11;
        r11 = (long) r12;	 Catch:{ all -> 0x012c }
        r3 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r6 = r3.p;	 Catch:{ all -> 0x012c }
        if (r6 != 0) goto L_0x00d7;
    L_0x00d5:
        r3.p = r13;	 Catch:{ all -> 0x012c }
    L_0x00d7:
        r3 = r3.c;	 Catch:{ all -> 0x012c }
        r3 = r3.isEmpty();	 Catch:{ all -> 0x012c }
        if (r3 != 0) goto L_0x00f9;
    L_0x00df:
        r0 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r0 = r0.c;	 Catch:{ all -> 0x012c }
        r0 = r0.values();	 Catch:{ all -> 0x012c }
        r3 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r3 = r3.c;	 Catch:{ all -> 0x012c }
        r3 = r3.size();	 Catch:{ all -> 0x012c }
        r3 = new f.f0.i.p[r3];	 Catch:{ all -> 0x012c }
        r0 = r0.toArray(r3);	 Catch:{ all -> 0x012c }
        r0 = (f.f0.i.p[]) r0;	 Catch:{ all -> 0x012c }
        goto L_0x00f9;
    L_0x00f8:
        r11 = r4;
    L_0x00f9:
        r3 = f.f0.i.g.u;	 Catch:{ all -> 0x012c }
        r6 = new f.f0.i.m;	 Catch:{ all -> 0x012c }
        r7 = "OkHttp %s settings";
        r13 = new java.lang.Object[r13];	 Catch:{ all -> 0x012c }
        r8 = f.f0.i.g.this;	 Catch:{ all -> 0x012c }
        r8 = r8.d;	 Catch:{ all -> 0x012c }
        r13[r1] = r8;	 Catch:{ all -> 0x012c }
        r6.m7729init(r10, r7, r13);	 Catch:{ all -> 0x012c }
        r3.execute(r6);	 Catch:{ all -> 0x012c }
        monitor-exit(r2);	 Catch:{ all -> 0x012c }
        if (r0 == 0) goto L_0x012b;
    L_0x0110:
        r10 = (r11 > r4 ? 1 : (r11 == r4 ? 0 : -1));
        if (r10 == 0) goto L_0x012b;
    L_0x0114:
        r13 = r0.length;
    L_0x0115:
        if (r1 >= r13) goto L_0x012b;
    L_0x0117:
        r2 = r0[r1];
        monitor-enter(r2);
        r3 = r2.b;	 Catch:{ all -> 0x0128 }
        r3 = r3 + r11;
        r2.b = r3;	 Catch:{ all -> 0x0128 }
        if (r10 <= 0) goto L_0x0124;
    L_0x0121:
        r2.notifyAll();	 Catch:{ all -> 0x0128 }
    L_0x0124:
        monitor-exit(r2);	 Catch:{ all -> 0x0128 }
        r1 = r1 + 1;
        goto L_0x0115;
    L_0x0128:
        r10 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x0128 }
        throw r10;
    L_0x012b:
        return;
    L_0x012c:
        r10 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x012c }
        throw r10;
    L_0x012f:
        r10 = "TYPE_SETTINGS length %% 6 != 0: %s";
        r12 = new java.lang.Object[r13];
        r11 = java.lang.Integer.valueOf(r11);
        r12[r1] = r11;
        f.f0.i.e.c(r10, r12);
        throw r0;
    L_0x013d:
        r10 = "TYPE_SETTINGS streamId != 0";
        r11 = new java.lang.Object[r1];
        f.f0.i.e.c(r10, r11);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.i.o.v(f.f0.i.o$b, int, byte, int):void");
    }

    public final void w(b bVar, int i, int i2) throws IOException {
        if (i == 4) {
            long J = ((long) this.a.J()) & 2147483647L;
            i = (J > 0 ? 1 : (J == 0 ? 0 : -1));
            if (i != 0) {
                f fVar = (f) bVar;
                if (i2 == 0) {
                    synchronized (g.this) {
                        g gVar = g.this;
                        gVar.m += J;
                        gVar.notifyAll();
                    }
                    return;
                }
                p n = g.this.n(i2);
                if (n != null) {
                    synchronized (n) {
                        n.b += J;
                        if (i > 0) {
                            n.notifyAll();
                        }
                    }
                    return;
                }
                return;
            }
            e.c("windowSizeIncrement was 0", Long.valueOf(J));
            throw null;
        }
        e.c("TYPE_WINDOW_UPDATE length !=4: %s", Integer.valueOf(i));
        throw null;
    }
}
